/**
 * 
 */
package com.service.impl;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSON;
import com.contants.ResultContants;
import com.entity.SysUser;
import com.mapper.SysUserMapper;
import com.service.UserService;
import com.utils.JsonResult;
/**
 *@name    中文名称
 *@description spring事务注解
 *@time    创建时间:2020年8月11日下午4:33:58
 *@return
 *@author   张孜
 *@history 修订历史（历次修订内容、修订人、修订时间等）
 */
@Service
@Transactional(rollbackFor   =  Exception.class)
public class userServiceImpl implements UserService{

	@Autowired
	private SysUserMapper sysUserMapper;
	@Override
	public JsonResult selectUserList(SysUser user) {
		try{
			List<SysUser> userList = sysUserMapper.selectUserList(user);
			return new JsonResult(ResultContants.successCode,"查询成功",userList);
		}catch (Exception e) {
			e.printStackTrace();
		}
		return new JsonResult(ResultContants.failCode,"查询失败！","");
	}
	@Override
	public SysUser queryUserByUserName(SysUser sysUser) {
		try{
			SysUser user=new SysUser();
			user.setUserName(sysUser.getUserName());
			List<SysUser> selectUserList = sysUserMapper.selectUserList(user);
			return selectUserList.get(0);
		}catch (Exception e) {
			e.printStackTrace();
		}
		return new SysUser();
	}


}
